<?php

class Add extends TPage
{
    private $backupManager;

	public function onLoad($params)
	{
		parent::onLoad($params);
        $this->backupManager = $this->Application->Modules['backups'];
	}
	
	public function createBackupButtonClicked($sender, $params)
	{
		if($this->Page->IsValid)
		{
		
			$result = $this->backupManager->addBackup(
												$this->datetime->getDateTime(),
												String::format($this->description->Text)
											);
			if($result)
			{
				$this->info->Text = '<p>'.Prado::localize('Changes saved').'</p>';
				$this->clearForm();
			}
			else
				$this->info->Text = '<p>'.Prado::localize('Changes not saved').'</p>';
		}	
	}
	
	public function clearForm()
	{
		$this->description->Text = '';
	}
}

?>